<?php
/**
 * User: roman
 * Date: 30.06.11
 * Time: 14:06
 */

namespace Managers;
class TagsGroup extends BaseManager {

    protected $__table = '\Catalog\TagGroup';

    public function getList() {

        $res = $this->_em->createQueryBuilder()
                ->select('gr')
                ->from($this->__table, 'gr')
                ->getQuery()
                ->getArrayResult();

        foreach($res as $key => $value) {

            $res[$key]['tags'] = $this->_em->createQueryBuilder()
                    ->select('tag')
                    ->from('\Catalog\Tags', 'tag')
                    ->where('tag.group = :id')
                    ->setParameter('id', $value['id'])
                    ->getQuery()
                    ->getArrayResult();
        }
        
        return $res;
    }

}
